<template>
	<div class="maxbox">
		
	
	<div class="spike">
		<div class="huise">
			
		</div>
		<!-- 顶部区域 -->
		<header class="spike-top">
			<!-- 左边区域 -->
			<div class="top-left">
				<!-- 镂空的区域 -->
				<div class="top-left-swiper swiper">
					<ol class="swiper-wrapper">
						<li class="swiper-slide" v-for="item in spikeList" :key="item.id">
							<nav class="title-time"> 
								<strong>限时特惠</strong>
								<!-- 由v-html解析的标签是不能直接加载表层选择器:将相关的选择器做成穿透/深度加载 -->
								<label v-html="fiterTimes(item.times)"></label>
							</nav>
							<div class="contain">
								<article>
									<h4>仅限{{item.num}}个</h4>
									<img :src="item.imgURL" >
									<p>{{item.city}}</p>
								</article>
								<aside>
									<h3>{{item.title}}</h3>
									<p>
										￥<strong>{{item.price}}</strong>起<em>{{item.oldprice}}</em>
									</p>
								</aside>
							</div>
						</li>
						
					</ol>
				</div>
			</div>
			<!-- 右边区域 -->
			<div class="top-right">
				<article>
					<h3>
						新品推荐<i class="iconfont">&#xe658;</i>
					</h3>
					<aside>
						<h4>{{newsList.title}}</h4>
						<p>
							￥<strong>{{newsList.price}}</strong>起
						</p>
					</aside>
				</article>
				<article>
					<h3>
						爆品线路<i class="iconfont">&#xe658;</i>
					</h3>
					<aside>
						<h4>{{hotList.title}}</h4>
						<p>
							￥<strong>{{newsList.price}}</strong>起
						</p>
					</aside>
				</article>
			</div>
		</header>
		<!-- 底部区域 -->
		<ul class="spike-bottom">
			<li>
				<router-link to="/">
					<h3>宝藏小城</h3>
					<p>挖掘小城魅力</p>
				</router-link>
			</li>
			<li>
				<router-link to="/">
					<h3>秋色播报</h3>
					<p>赏秋好去处</p>
				</router-link>
			</li>
			<li>
				<router-link to="/">
					<h3>侠魅榜</h3>
					<p>每月最佳游记</p>
				</router-link>
			</li>
		</ul>
	</div>
</div>
</template>

<script>
	// 引入vue周期函数
	import{onMounted} from 'vue';
	// 2.引入Swiper的动态组件
	import Swiper,{
		Autoplay,
		EffectCoverflow,
		EffectCube,
	}from 'swiper'
	// 3.swiper组件应用配置
	Swiper.use([Autoplay,EffectCoverflow,EffectCube])
	
	export default{
		name:'Spike',
		data(){
			
			return{
				date:new Date(),
				spikeList : [
					{ id : 1, times : 1637899200000, num : 100, city:'北京', imgURL :'images/spike-list01.jpg', title : '[感恩节·奇妙披萨之旅]11.27周六，必胜客邀你一起动手，变身小小厨师，制作美味的Pizza，了解披萨历史，一起分享披萨的魅力！（北京同城亲子半日）', price : 98, oldprice : 128, },
					{ id : 2, times : 1638298200000, num : 50, city:'杭州出发', imgURL :'images/spike-list02.png', title : '[山野旅行家•径山古道]江南五大禅院之首，日本名僧学禅扬法，寻觅禅茶文化心归自然，踏竹林古道蜿蜒，寻寺庙钟声悠扬，俯览高山茶园，探秘九龙幽瀑 ，唐代古刹祈福（足不出杭）', price : 48, oldprice : 120, },
					{ id : 3, times : 1638328800000, num : 50, city:'杭州出发', imgURL :'images/spike-list03.jpg', title : '[五泄觅秋] 杭州、绍兴凭身份证免门票！诸暨五泄觅秋色，秋风迷醉银杏林，船游诸暨湖，高山流水瀑布成群，秋叶斑斓银杏红枫正当时，赴越国故地、西施故里，共赏一场金秋盛宴', price : 90, oldprice : 130, },
					{ id : 4, times : 1638328800000, num : 50, city:'杭州', imgURL :'images/spike-list04.jpg', title : '[山野旅行家 • 西湖寻秋] 西湖深处，隐秘胜景，探访千年古刹法喜寺，寻觅山水禅踪，手工树叶拓印，感受自然乐趣，行走山水画卷，俯览龙井茶田，漫步九溪十八涧，徒步十里琅珰！', price : 28, oldprice : 68, },
					{ id : 5, times : 1639288000000, num : 50, city:'杭州出发', imgURL :'images/spike-list05.jpg', title : '[秋意浓·孙家岭古道]徒步绍兴孙家岭-五百岗，登顶雄鹅峰，疾行秋色大尖山！探浙江高山草甸！浙江小武功山！线路强度适中，秋游徒步推荐！（柿子高挂，满山芦苇飘扬时）', price : 48, oldprice : 120, },
					{ id : 6, times : 1638260200000, num : 20, city:'陵水清水湾出发', imgURL :'images/spike-list06.jpg', title : '[瑜伽行·三瑜伽旅修]元旦和Kiki老师去海南迎接新年，共度三瑜伽42周年生日，从清水湾到三亚，享阳光沙滩，海边练习，探秘丛林瀑布，小众景点，分界洲岛，6天5晚海岛静修', price : 4900, oldprice : 6200, },
					{ id : 7, times : 1638247200000, num : 10, city:'拉萨', imgURL :'images/spike-list07.jpg', title : '[瑜伽行·喜马拉雅颂钵工作坊]跨年去西藏拉萨，专业颂钵师资认证培训，导师拉姆，3整天密集课程与圣地圣湖寺庙禅修之旅，深入当地藏族人家，学习与体验双重收获，特别的新年礼物', price : 5280, oldprice : 6880, }
				],
				newsList : {
					id : 1,
					title : '江南5日亲子游',
					price : 1350,
				},
				hotList : {
					id : 1,
					title : '贵州探洞亲子游',
					price : 3280,
				}
			}
		},
		setup(){
			onMounted( ()=>{ 
				new Swiper( '.top-left-swiper ' , {
					// 循环播放
					loop:true,
					
					//设置播放项：时间，不停止，手指经过不暂停自动
					autoplay:{
						delay:3000,
						stopOnLastSlide:false,
						disableOnInteraction:true
					}
				} )
			} )
		},
		computed:{
			fiterTimes(){
				return( x )=>{
					// 获取当前系统时间戳
					let now = this.date.getTime();
					//计算两个时间戳之间的差值
					let setupTime = x - now
					//计算提取天数+小时+分钟+秒数
					if(setupTime<0){
						return `0天<i>0</i>:<i>0</i>:<i>0</i>`
					}
					let dnum = Math.floor( setupTime / (24*60*60*1000));
					let hnum = Math.floor( setupTime / (60*60*1000)%24);
					let mnum = Math.floor( setupTime / (60*1000)%60);
					let snum = Math.floor( setupTime / 1000%60);
					//保证所有的输出都是两位数
					if(hnum <= 9){
						hnum = '0'+hnum;
					}
					if(mnum <= 9){
						mnum = '0'+mnum;
					}
					if(snum <= 9){
						snum = '0'+snum;
					}
					return `${dnum}天<i>${hnum}</i>:<i>${mnum}</i>:<i>${snum}</i>`
					
				}
			}
		},
		mounted(){
			setInterval(()=>{
				this.date = new Date();
			} ,1000)
		}
	}
</script>

<style scoped>
	a{
		text-decoration: none;
		color: black;
	}
	.maxbox{
		width: 100%;
		height: 8.6rem;
		background-color: white;
		border-radius: 0.2rem;
	}
	/* 最外层 */
	.spike{
		width: 95%;
		padding-top: 0.3rem;
		margin: 0.25rem auto;
		height: 8rem;
	}
	/* 顶部样式 */
	.spike-top{
		height: 65%;
		display: flex;
		justify-content: space-between;
	}
	/* 顶部的左边 */
	.spike-top .top-left{
		width: 55%;
		height: 100%;
		background-image: url(../../../assets/img/spike01.png);
		background-repeat: no-repeat;
		/* 背景图片尺寸 */
		background-size: 100% 100%;
		/* background-size: cover; */
	}
	/* 滑动区域的样式 */
	.top-left .top-left-swiper{
		width: 94%;
		height: 100%;
		margin: 0 auto;
		
	}
	.top-left .top-left-swiper ol{
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.top-left .top-left-swiper ol li{
		height: 100%;
		width: 100%;
	}
	.top-left .top-left-swiper ol .title-time{
		line-height: 0.8rem;
		color: white;
		font-size: 0.4rem;
		display: flex;
	}
	.top-left .top-left-swiper ol .title-time strong{
		font-weight: bold;
		width: 40%;
		margin-left: 0.05rem;
	}
	.top-left .top-left-swiper ol .title-time label{

		font-size: 0.25rem;
		flex: 1;
		text-align: right;
	}
	.top-left .top-left-swiper ol .title-time label :deep(i){
		display: inline-block;
		width: 0.4rem;
		color: #ff0000;
		height: 0.4rem;
		font-weight: bold;
		border-radius: 0.2rem;
		background-color: white;
		text-align: center;
		line-height: 0.4rem;
		margin: 0 0.08rem;
	}
	
	/* 图片区域 */
	.top-left-swiper .contain{
		height: 4rem;
		width: 100%;
		border-radius: 0.3rem;
		
	}
	.top-left-swiper .contain article{
		position: relative;
		width: 100%;
		height: 60%;
		background-color: #535353;
	}
	.top-left-swiper .contain article img{
		width: 100%;
		height: 100%;
		
		/* 左上 右上 右下 左下 */
		border-radius: 0.2rem 0.2rem 0 0;
	}
	.top-left-swiper .contain article h4{
		position: absolute;
		left: 0;
		top: 0;
		background-image: linear-gradient(#ffe414,#e6c81a);
		padding: 0.08rem 0.15rem;
		border-radius: 0.2rem 0 0.2rem 0;
	}
	.top-left-swiper .contain article p{
		position: absolute;
		top: 70%;
		background-color: rgba(0,0,0,0.7);
		color: white;
		padding: 0.1rem 0.25rem;
		border-radius: 0 0.16rem 0.16rem 0;
	}
	.top-left-swiper .contain aside{
		height: 38%;
		background-color: white;
		border-radius: 0 0 0.2rem 0.2rem;
		padding: 0.1rem;
	}
	.top-left-swiper .contain aside h3{
		font-size: 0.35rem;
		font-weight: bold;
		line-height: 0.5rem;
		height: 1rem;
		/* 一行文字省略号: 省略号+溢出隐藏+禁止换行 [超出宽度溢出隐藏且同省略号代替] */
		/* overflow: hidden;
		text-overflow: ellipsis;  省略号
		word-spacing: normal; 禁止换行 */
		/* 多行文字做省略号:最后一行文字超过高度,溢出隐藏且用省略符合代替 */
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2; /* 高度有关 */
		/* 超出盒子外的文本用省略号代替 */
		-webkit-box-orient: vertical;
		
		
	}
	.top-left-swiper .contain aside p{
		font-size: 0.3rem;
		line-height: 0.6rem;
		color: #ff7100;
		font-weight: bold;
	}
	.top-left-swiper .contain aside p em{
		color:grey;
		font-size: 0.2rem;
		text-decoration: line-through;
		padding-left: 0.2rem;
	}
	
	/* 顶部的右边 */
	.spike-top .top-right{
		width: 45%;
		height: 100%;
		background-image: url(../../../assets/img/spike02.png);
		background-repeat: no-repeat;
		/* 背景图片尺寸 */
		background-size: 100% 100%;
	}
	.top-right article{
		width: 90%;
		height: 49%;
		margin: 0 auto;
	}
	.top-right article h3{
		color: white;
		font-size: 0.4rem;
		line-height: 0.8rem;
		font-weight: bold;
		
	}
	.top-right article h3 i{
		padding-left: 0.1rem;
	}
	.top-right article aside{
		width: 100%;
		border-radius: 0.2rem;
		background-color: white;
		text-indent: 1em;
	}
	.top-right article aside h4{
		font-size: 0.4rem;
		font-weight: bold;
		line-height: 0.8rem;
	}
	.top-right article aside p{
		line-height: 0.5rem;
		color: #ff7100;
		font-size: 0.3rem;
	}
	.top-right article aside p strong{
		font-size: 0.4rem;
		font-weight: bold;
	}
	.top-right article:nth-child(1){
		border-bottom: 0.03rem solid white;
	}
	
	
	/* 底部样式 */
	.spike-bottom{
		height: 30%;
		width: 100%;
		margin-top: 0.4rem;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.spike-bottom li{
		width: 32%;
		height: 100%;
		overflow: hidden;
		background-size: 100% 100%;
		
	}
	.spike-bottom li h3{
		line-height: 0.8rem;
		font-size: 0.35rem;
		font-weight: bold;
		text-indent: 1em;
	}
	.spike-bottom li p{
		font-size: 0.25rem;
		text-indent: 2em;
		color: gray;
	}
	.spike-bottom li:first-child{
		background-image: url(../../../assets/img/spike03.jpg);
		border-radius: 0.3rem 0 0 0.3rem;
		
	}
	.spike-bottom li:nth-child(2){
		background-image: url(../../../assets/img/spike04.png);

	}
	.spike-bottom li:last-child{
		background-image: url(../../../assets/img/spike05.png);
			border-radius: 0 0.3rem 0.3rem 0;
	}
</style>
